package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.LocationXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：郑皓
 * 创建时间：2018/1/10 17:20
 * 修改备注：
 * ================================================
 */
public class BusinessTechnologies {


    /**
     * 技术大全列表
     *
     * @param keywords    关键字
     * @param code  技术分类
     * @param sortType    排序类型 ： 空 or 0--推荐分类  1--最新  2--最热
     * @param page        页码
     * @param limit       条数
     */
    public static void technologyList(Activity activity, int page, int limit, String keywords, String code, String sortType, String queryDataType,Handler handler) {

        HttpParams params = new HttpParams();
        params.put("page", String.valueOf(page));
        params.put("perPage", String.valueOf(limit));
        params.put("keyWords", keywords);
        params.put("typeId", code);
        params.put("sortStatus", sortType);
        params.put("queryDataType", queryDataType);



        OkHttpUtil.get(activity, URL.URL_TECHNOLOGIES, "", params,
                handler, MSG.MSG_TECHNOLOGIES_SUCCESS, MSG.MSG_TECHNOLOGIES_FIELD);

    }

    /**
     * 获取技术大全类型
     *
     * @param activity
     * @param handler
     */
    public static void primaryClassificationByTechnogy(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("pCode","BIZ_EXPERT_TYPE");
        OkHttpUtil.get(activity, URL.URL_SHARE_FARM_TYPE, "", params,
                handler, MSG.MSG_TECHNOLOGIES_TYPE_SUCCESS, MSG.MSG_TECHNOLOGIES_TYPE_FIELD);

    }

    /**
     * 发布评论
     *
     * @param commentObjectId 评论的对象ID
     *                        commentType     评论的对象的类型（0-技术大全 1-咨询详情[MessageContentActivity] 2-视频 3-专题活动 4-农事操作详情）
     * @param content         评论的内容
     */
    public static void publishComment(Activity activity, String commentObjectId, String content, String commentType, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("commentObjectId", commentObjectId);
        params.put("commentType", commentType);
        params.put("content", content);
        params.put("userAccId", UserXML.getUserId(activity));


        OkHttpUtil.post(activity, URL.URL_PUBLISH_COMMENT, "", params,
                handler, MSG.MSG_PUBLISH_COMMENT_SUCCESS, MSG.MSG_PUBLISH_COMMENT_FIELD);

    }

    /**
     * 获取某个对象的所有评论
     *
     * @param objectId 评论对象ID
     * @param page
     * @param limit
     * @param commentType 评论的对象的类型（0-技术大全 1-咨询详情[MessageContentActivity] 2-视频 3-专题活动 4-农事操作详情）
     */
    public static void getCommentList(Activity activity, String objectId, String commentType, int page, int limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("objectId", objectId);
        params.put("commentType", commentType);
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));


        OkHttpUtil.post(activity, URL.URL_GET_COMMENT_LIST, "", params,
                handler, MSG.MSG_GET_COMMENT_LIST_SUCCESS, MSG.MSG_GET_COMMENT_LIST_FIELD);

    }

    /**
     * 评论点赞
     *
     * @param activity
     * @param commentId 评论id
     * @param handler
     */
    public static void clickPraise(Activity activity, String commentId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("commentId", commentId);

        OkHttpUtil.post(activity, URL.URL_CLICK_PRAISE, "", params,
                handler, MSG.MSG_CLICK_PRAISE_SUCCESS, MSG.MSG_CLICK_PRAISE_FIELD);

    }
}
